package com.jeejam.product.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.jeejam.framework.base.service.impl.BaseServiceImpl;
import com.jeejam.product.dao.AttributeMapper;
import com.jeejam.product.pojo.Attribute;
import com.jeejam.product.service.AttributeService;

@Service
public class AttributeServiceImpl extends BaseServiceImpl implements AttributeService{
	
	private AttributeMapper attributeMapper;
	
	public AttributeMapper getAttributeMapper() {
		return attributeMapper;
	}

	@Resource
	public void setAttributeMapper(AttributeMapper attributeMapper) {
		this.attributeMapper = attributeMapper;
		this.baseMapper = attributeMapper;
	}

	@Override
	public List<Attribute> findByTypeId(int typeId) {
		return attributeMapper.selectByTypeId(typeId);
	}

	@Override
	public int countsByTypeId(int typeId) {
		return attributeMapper.countsByTypeId(typeId);
	}

	@Override
	public List<Attribute> findByTypeIdAndPage(int typeId, int page, int pageSize) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("typeId", typeId);
		params.put("begin", (page-1)*pageSize);
		params.put("pageSize", pageSize);
		return attributeMapper.selectByTypeIdAndPage(params);
	}

}
